<!DOCTYPE html>
<html lang="en">

<head>
 <meta charset="UTF-8">
 <meta name="viewport"
  content="width=device-width, initial-scale=1.0, minimum-scale=1,maximum-scale=1,user-scalable=no">
 <meta http-equiv="X-UA-Compatible" content="ie=edge">
 <title data-ch="恐龙探险" data-en="Dinosaur Adventure" class="document_title">恐龙探险</title>
 <script src="js/jquery-3.3.1.min.js"></script>
 <script src="js/common.js"></script>
 <script src="js/rem.js"></script>
 <script src="js/layer.js"></script>
 <script type="text/javascript">
  isLogin();
 </script>
 <link rel="stylesheet" href="css/common.css">
 <link rel="stylesheet" href="css/index.css">
</head>

<body>
 <!--头部-->
 <div class=" jui_top_bar">
  <a class="jui_top_left" href="javascript:history.back(-1)"><img src="icons/back.png"></a>
  <div class="jui_top_middle font_weight" data-ch="添加资料" data-en="Add">添加资料</div>
 </div>
 <!-- 头部end -->
 <!-- 内容部分 -->
 <div class="reg_box jui_main" style="margin-top:0.5rem; padding:0.32rem 0.5rem 0;">
  <div class="reg_details border_radius05 latout_mask" style="padding:0.6rem 0.5rem;">
   <div class="reg_list" style="margin-bottom:0.6rem;">
    <div class="reg_list_title f30 col_fff" style="margin-bottom:0.1rem;">WhatsApp:</div>
    <input id="whatsApp" type="text">
   </div>
   <div class="reg_list">
    <div class="reg_list_title f30 col_fff" style="margin-bottom:0.1rem;">Telegram:</div>
    <input type="text" id="telegram">
   </div>
   <div class="reg_btn col_fff" style="margin-top:0.9rem; margin-bottom:0.1rem;" id="lianxi_btn" data-ch="提交" data-en="submit">提交</div>
  </div>
 </div>

 <script>
  $(function(){
   var language_type=localStorage.getItem("language_type");
   var qq = window.location.href.split("?")[1].split("&&")[0].split("=")[1];
   var wx = window.location.href.split("?")[1].split("&&")[1].split("=")[1];
   console.log(qq, wx);
   if(qq !='' && wx!=""){
    $(".jui_top_middle").html(language_type == 1 ? "更改资料" : 'Change information');
    $("#whatsApp").attr("value", qq);
    $("#telegram").attr("value", wx)
   } else {
    $(".jui_top_middle").html(language_type == 1 ? "添加资料" : 'Add information')
   }
   $("#lianxi_btn").click(function(){
    var whatsApp = $("#whatsApp").val();
    var telegram = $("#telegram").val();
    if(!whatsApp){
     box_timer(language_type == 1 ? "whatsApp不能为空" : 'whatsApp cannot be empty');
    } else if(!telegram){
     box_timer(language_type == 1 ? "telegram不能为空" : 'telegram cannot be empty');
    } else {
     var data = {
      uid: localStorage.getItem("u_id"),
      token: localStorage.getItem("token"),
      language_type: localStorage.getItem("language_type"),
      m_wx: telegram,
      m_qq: whatsApp
     }
     $.ajax({
      type: 'post',
      url: baseURL + '/index.php?m=user&c=setup_user_info',
      data: data,
      success: function success(data) {
       data = JSON.parse(data);
       is_login(data);
       box_timer(data.msg);
       if(data.code == 1){
        setTimeout(function(){
         window.history.go(-1);
        },1000)
       }
      }
     })
    }
   })
   
  })
 </script>
</body>

</html>